<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>删除文章</title>
<link rel="stylesheet" href="../webjars/layui/2.5.6/css/layui.css"
	media="all">


</head>
<body>
	<fieldset class="layui-elem-field layui-field-title"
		style="margin-top: 20px;">
		<legend>删除文章</legend>
	</fieldset>
	<form class="layui-form" action="">
		<div class="layui-form-item">
			<label class="layui-form-label">文章id</label>
			<div class="layui-input-block">
				<input v-model="tid" type="text" name="username" lay-verify="required"
					lay-reqtext="文章id不能为空！" placeholder="请输入(必填)" autocomplete="off"
					class="layui-input">
			</div>
		</div>
		
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button  type="submit" class="layui-btn" lay-submit=""
					lay-filter="demo1" @click.prevent="remove">删除提交</button>
				<button type="reset" class="layui-btn layui-btn-primary">重置</button>
			</div>
		</div>
		 <div class="layui-form">
  <table class="layui-table">
    <colgroup>
      <col width="150">
      <col width="150">
      <col width="200">
      <col>
    </colgroup>
    <thead>
      <tr>
        <th>文章ID</th>
        <th>文章标题</th>
      </tr> 
    </thead>
    <tbody @click="getval(a.tid)" v-for="a in list">
      <tr>
        <td>{{a.tid}}</td>
        <td>{{a.atitle}}</td>
      </tr>
    </tbody>
  </table>
</div>
</form>
		<!-- <div class="layui-form-item">
			<label class="layui-form-label">单行选择框</label>
			<div class="layui-input-block">
				<select name="interest" lay-filter="aihao">
					<option value=""></option>
					<option value="0">写作</option>
					<option value="1" selected="">阅读</option>
					<option value="2">游戏</option>
					<option value="3">音乐</option>
					<option value="4">旅行</option>
				</select>
			</div>
		</div> -->
		<!-- <div class="layui-form-item layui-form-text">
			<label class="layui-form-label">文本域</label>
			<div class="layui-input"E:/源辰培训/94班/二期/web/layout/04 商品添加.jpg"-block">
				<textarea placeholder="E:/源辰培训/94班/二期/web/layout/04 商品添加.jpg""请输入内容" class="layui-textarea"></textarea>
			</div>"E:/源辰培训/94班/二期/web/layout/04 商品添加.jpg"
		</div>
		<div class="layui-form-item">"E:/源辰培训/94班/二期/web/layout/04 商品添加.jpg"
			<button class="layui-btn" lay-submit="" lay-filter="demo2">跳转式提交</button>
		</div> -->
	</form>
<!-- vue -->
<script type="text/javascript"src="https://lib.baomitu.com/vue/2.6.12/vue.min.js"></script>
<!-- axios -->
<script type="text/javascript"src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.0/axios.min.js"></script>
<script src="../webjars/layui/2.5.6/layui.all.js" charset="utf-8"></script>
<script type="text/javascript">
	var v1 = new Vue({
	 el:".layui-form",
	 data:{
		
		tid:"",
		list:[],
	 },
	 created(){
		axios.post("../article/allArticle.s").then(res=>{
			this.list = res.data;
		})
	 },
	 methods:{
		 remove(){
			 var params = new URLSearchParams();
			 params.append("tid",this.tid);
			 axios.post("../article/removeArticle.s",params).then(res=>{
				 alert(res.data.msg);
				 location.reload();
			 })
		 },
		 getval(tid){
			 this.tid = tid;
		 }
	 },
	 mounted(){
		 
		 
		 layui.form.on('submit(demo1)',data=>{
			 /*  console.log(data.elem) //被执行事件的元素DOM对象，一般为button对象
			  console.log(data.form) //被执行提交的form对象，一般在存在form标签时才会返回
			  console.log(data.field)  *///当前容器的全部表单字段，名值对形式：{name: value}
			  return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
			});
	 },
	})
</script>
</body>
</html>